package com.distributed_lock_zk;

import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;

@Slf4j
public class Client {
    public static void main(String[] args) {
        Runnable runnable = () -> {
            ZkLockImpl zkLock = new ZkLockImpl();
            zkLock.tryLock();
            try {
                Thread.sleep(10000);
                log.info("线程 {} 执行了",Thread.currentThread().getId());
            } catch (Exception e) {
                e.printStackTrace();
            }finally {
                zkLock.unLock();
            }

        };

        for (int i = 0; i < 2; i++) {
            Thread thread = new Thread(runnable);
            thread.start();
        }
    }
    public void test(){



    }
}
